package com.yc.fastjson;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.PropertyNamingStrategy;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import lombok.Data;

@Data
public class JsonDemo {

    @JSONField(name ="test_id")
    private String testId;
    private String flowStatus;
    private String opId ;

    public static void main(String[] args) {
        SerializeConfig config = new SerializeConfig(); // 生产环境中，config要做singleton处理，要不然会存在性能问题
        config.propertyNamingStrategy = PropertyNamingStrategy.CamelCase;

        JsonDemo jsonDemo = new JsonDemo();
        jsonDemo.setFlowStatus("1");
        jsonDemo.setTestId("test");
        jsonDemo.setOpId("opId");
        String s = JSON.toJSONString(jsonDemo, config);
        System.out.println(s);
    }
}
